package com.crc.luojian.resolver.impl;

import com.crc.luojian.resolver.RequestResolver;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Parameter;

/**
 * @program: luojian-springframework
 * @description:
 * @author: luojian58
 * @create: 2021-06-11 10:16
 */
public class HttpServletRequestResolver implements RequestResolver {
    @Override
    public boolean support(Parameter parameter) {

        return ServletRequest.class.isAssignableFrom(parameter.getType());
    }

    @Override
    public Object resolveArgument(HttpServletRequest request, Parameter parameter) {
        Class<?> paramType = parameter.getType();
        if (ServletRequest.class.isAssignableFrom(paramType)) {
            return request;
        }
        return null;
    }
}
